/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.gradleshell.shell.cmds;

import org.gradleshell.shell.gradle.ICommandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
import org.springframework.shell.core.annotation.CliCommand;
import org.springframework.stereotype.Component;

/**
 *
 * @author jxcommerce<g2commerce@gmail.com>
 */
@Component
public class MonitorSrcCmd implements CommandMarker{
    @Autowired
    ICommandService commandService;
    @CliAvailabilityIndicator({"start-monitor","stop-monitor"})
    public boolean isCommandAvailable() {
        return true;
    }
    @CliCommand(value = "start-monitor", help = "start monitoring source files")
    public String startMonitor(){
        if(commandService.isMonitorSrc()){
            return "source files monitoring already running";
        }else{
            return commandService.startMonitorSrc();
        }
    }
    @CliCommand(value = "stop-monitor", help = "stop monitoring source files")
    public String stopMonitor(){
        if(commandService.isMonitorSrc()){
            return commandService.stopMonitorSrc();
        }else{
            return "souirce file monitoring not running";
        }
    }
}
